from pydantic import BaseModel, Field
from typing import Literal, Union, List
from enum import Enum

class Role(Enum):
    ASSISTANT = "assistant"
    USER = "user"
    SYSTEM = "system"
    TOOL = "tool"
    
class MessageContent(BaseModel):
    type: str = 'text'
    text: str

class Message(BaseModel):
    role: Role
    content: Union[str, List[MessageContent]]
    model_config = {
        "use_enum_values": True  # 序列化时使用枚举的 value
    }
    
class LLMChatMessage(BaseModel):
    id: str | None
    model: str | None
    messages: List[Message]
    stream: bool = True

class RobotChatMessage(LLMChatMessage):
    chat_id: str | None
    message_id: str | None
